package mypackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.EncodedImage;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen
{
	private VerticalFieldManager vfm;
	private static VerticalFieldManager headerManager;
	private HorizontalFieldManager hfm;
    /**
     * Creates a new MyScreen object
     */
    public MyScreen()
    {        
    	
    	headerManager = new VerticalFieldManager( Manager.USE_ALL_WIDTH | Manager.FIELD_HCENTER) {
			public void paint(Graphics graphics) 
            {
			   
			   Bitmap backgroundBitmap = Bitmap.getBitmapResource("log.jpg");
               //Draw the background image and then call paint.
               graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap,0, 0);
                super.paint(graphics);
            }			
		};
        // Set the displayed title of the screen   
    	MyCustomButton mcb1 = new MyCustomButton("50x50.gif",70,70);
    	headerManager.add(mcb1);
        setTitle(headerManager);
        
        vfm = new VerticalFieldManager(FIELD_HCENTER);
        hfm = new HorizontalFieldManager(FIELD_VCENTER);
        
        GridFieldManager gfm = new GridFieldManager(4, 3, FIELD_HCENTER);
        for(int i=0;i<2;i++){
        	gfm.add(new NullField());
            gfm.add(new NullField());
            gfm.add(new NullField());
            
        	Bitmap bitmap = Bitmap.getBitmapResource("x.png");
            BitmapButtonField b = new BitmapButtonField(bitmap, bitmap);
            BitmapButtonField b1 = new BitmapButtonField(bitmap, bitmap);
            gfm.add(b);
            gfm.add(new NullField());
            gfm.add(b1);
            
        }
        
      // MyCustomButton mcb = new MyCustomButton("50x50.gif",70,70);
        
        
        //gfm.add(new NullField());
        //gfm.add(mcb);
        hfm.add(gfm);
        vfm.add(hfm);
        add(vfm);
    }
}
